package li.rafa.UrlShortener.shared;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ShortUrl implements Serializable {
	
	
	private static final long serialVersionUID = -6152749114388142250L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private String originalUrl;

	@Persistent
	private String code;

	protected ShortUrl() {}
	
	public ShortUrl(String originalUrl) {
		this.originalUrl = originalUrl;		
	}

	public String getCode() {
		return code;
	}
	
	public String getOrginalUrl() {
		return originalUrl;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	@Override
	public String toString() {
		return code+" : "+originalUrl;
	}
}
